package org.model;



import java.awt.Component;
import java.awt.Container;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;

import javax.swing.JFrame;


public abstract class QParentFrame extends JFrame implements WindowListener{
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private int width = 500 ;
	private int height = 500 ;
	protected Container mainContainer;
	protected int FrameX;
	protected int FrameY;
	 
	
	public void setWidth(int width) {
		this.width = width;
	}
	public void setHeight(int height) {
		this.height = height;
	}
	protected void showWindow()
	{
		
		setSize(width, height);
		int WHeight = (int) getToolkit().getScreenSize().getHeight();
		int Wwidht = (int) getToolkit().getScreenSize().getWidth();
		FrameX = (Wwidht - width)/2;
		FrameY = (WHeight - height)/2;
		
		setLocation(FrameX, FrameY);
		setDefaultCloseOperation(EXIT_ON_CLOSE);
		setVisible(true);
		//paintAll(getGraphics());
	}
	
	
	
	public QParentFrame(String text)
	{
		super(text);
		mainContainer = getContentPane();
	}
	protected void addChildComponent(Component arg)
	{
		mainContainer.add(arg);
	}
	
	@Override
	public void windowActivated(WindowEvent arg0) {

		
	}

	@Override
	public void windowClosed(WindowEvent arg0) {

		
	}



	@Override
	public void windowDeactivated(WindowEvent arg0) {

		
	}

	@Override
	public void windowDeiconified(WindowEvent arg0) {

		
	}

	@Override
	public void windowIconified(WindowEvent arg0) {

		
	}

	@Override
	public void windowOpened(WindowEvent arg0) {

		
	}
		
}
